import Stripe from 'stripe';

if (!process.env.STRIPE_SECRET_KEY) {
  throw new Error('STRIPE_SECRET_KEY is required in environment variables');
}

// Initialize Stripe with configuration
export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
  maxNetworkRetries: 3,
  timeout: 10000, // 10 seconds
  appInfo: {
    name: 'Express TypeScript Backend',
    version: '1.0.0',
  },
});

// Stripe webhook endpoint secret
export const STRIPE_WEBHOOK_SECRET = process.env.STRIPE_WEBHOOK_SECRET;

// Export Stripe types for use in other files
export type { Stripe } from 'stripe';

export default stripe;